<%@page import="com.alibaba.fastjson.JSON"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.pay.sdk.service.channel2.*"%>
<%@ page import="com.alibaba.fastjson.*"%>

<%
	// [重要]该页面仅为示例页面，在正式使用时，应当先对传入参数进行安全性检查和过滤，防止XSS等攻击。SDK中的方法没有对传入的参数进行任何检查和过滤。
	
	String type = request.getParameter("redirect_type");
	
	 if("alipay_bar".equals(type)) { 		// 查询
		String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"), "UTF-8");
		String total_fee = new String(request.getParameter("total_fee").getBytes("ISO-8859-1"), "UTF-8");
		String body = new String(request.getParameter("body").getBytes("ISO-8859-1"), "UTF-8");
		String auth_code = new String(request.getParameter("auth_code").getBytes("ISO-8859-1"), "UTF-8");
		String acquirer_type = new String(request.getParameter("acquirer_type").getBytes("ISO-8859-1"), "UTF-8");
		String device_info = new String(request.getParameter("device_info").getBytes("ISO-8859-1"), "UTF-8");
		String bank_card_limit = new String(request.getParameter("bank_card_limit").getBytes("ISO-8859-1"), "UTF-8");
		String time_expire = new String(request.getParameter("time_expire").getBytes("ISO-8859-1"), "UTF-8");
		String attach = new String(request.getParameter("attach").getBytes("ISO-8859-1"), "UTF-8");
		// 【重要】出于安全考虑，在调用函数前，需要对上面的参数进行防护过滤等操作
		out.println(ChanneTwolPay.barPay(out_trade_no, total_fee, body, auth_code, device_info, acquirer_type, bank_card_limit, time_expire, attach));
	}else if("alipay_scan".equals(type)){
		String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"), "UTF-8");
		String total_fee = new String(request.getParameter("total_fee").getBytes("ISO-8859-1"), "UTF-8");
		String body = new String(request.getParameter("body").getBytes("ISO-8859-1"), "UTF-8");
		String device_info = new String(request.getParameter("device_info").getBytes("ISO-8859-1"), "UTF-8");
		String notify_url = new String(request.getParameter("notify_url").getBytes("ISO-8859-1"), "UTF-8");
		String acquirer_type = new String(request.getParameter("acquirer_type").getBytes("ISO-8859-1"), "UTF-8");
		String bank_card_limit = new String(request.getParameter("bank_card_limit").getBytes("ISO-8859-1"), "UTF-8");
		String time_expire = new String(request.getParameter("time_expire").getBytes("ISO-8859-1"), "UTF-8");
		String attach = new String(request.getParameter("attach").getBytes("ISO-8859-1"), "UTF-8");
		// 【重要】出于安全考虑，在调用函数前，需要对上面的参数进行防护过滤等操作
		String reslt = ChanneTwolPay.scanPay(out_trade_no, total_fee, body, device_info, notify_url, acquirer_type, bank_card_limit, time_expire, attach);
		JSONObject obj = JSONObject.parseObject(reslt);
		out.println(obj.get("code_url"));
	}
%>